<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>按奇偶排序数组</title>
</head>
<body>
<script>
    const arr = [1, 5, 6, 3, 8, 7, 10];//[1,3,7,9,4,6,8]
    const newArr = [];
    for (let i = 0; i < arr.length; i++) {
        if (arr[i] % 2 === 0) {
            newArr.push(arr[i]);
        } else {
            newArr.unshift(arr[i]);
        }
    }
    console.log(newArr);
</script>
</body>
</html>